package repair

import (
	"common/pb"
	"common/rpc"
	"context"
	"storj.io/drpc/drpcconn"
)

func getDrpcClient(ctx context.Context, addr string, dialer *rpc.TcpDialer) (pb.DRPCMetainfoClient, func() error, error) {
	c, err := dialer.DialTLS(ctx, addr)
	if err != nil {
		return nil, nil, err
	}
	// convert the net.Conn to a drpc.Conn
	conn := drpcconn.New(c)
	return pb.NewDRPCMetainfoClient(conn), func() error {
		return conn.Close()
	}, nil
}
